package lc.q51_100;

import lc.q101_150.ListNode;

public class Q82 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode preHead = new ListNode();
        preHead.next = head;
        ListNode current = preHead;
        while (current.next != null && current.next.next != null) {
            if (current.next.val == current.next.next.val) {
                int val = current.next.val;
                while (current.next != null && current.next.val == val) {
                    current.next = current.next.next;
                }

            } else {
                current = current.next;
            }
        }
        return preHead.next;
    }

    public static void main(String[] args) {
        ListNode listNode = ListNode.buildByArr(new int[]{1,2,3,3,4,4,5});
        Q82 q82 = new Q82();
        ListNode listNode1 = q82.deleteDuplicates(listNode);
        System.out.println(listNode1);
    }
}
